监控RabbitMQ
最后于 更新
RabbitMQ当前提供两种方式接入监控数据
方法一:使用内置Prometheus Plugin(推荐)
版本要求: RabbitMQ (version >= 3.8.0)
步骤如下:
- 在已经启动的RabbitMQ服务运行环境中,通过下列命令开启Prometheus插件
rabbitmq-plugins enable rabbitmq_prometheus
- 将以下配置添加到
configmap/apo-grafana-alloy-config
中,替换其中YOUR_RABBITMQ_SERVER_IP
变量
prometheus.scrape "rabbitmq" {
targets = [
{
__address__ = "YOUR_RABBITMQ_SERVER_IP:15692",
job = "integrations/rabbitmq",
},
]
scheme = "http"
scrape_interval = "60s"
forward_to = [prometheus.relabel.example.receiver]
}
注意 YOUR_RABBITMQ_SERVER_IP 替换时不加http或https前缀 , 如 192.168.1.1:15692
- 使用APO Grafana内携带的
RabbitMQ 官方指标
面板查看监控数据
方法二:使用社区开源Exporter(已集成进Alloy内)
版本要求: RabbitMQ (version >= 3.6.8), 更早的版本也可以支持,参考配置修改说明
步骤如下:
- 将以下配置添加到
configmap/apo-grafana-alloy-config
中, 下面是最基础的配置,替换其中YOUR_RABBITMQ_URL
变量
prometheus.exporter.rabbitmq "rabbitmq_demo" {
rabbit_url = YOUR_RABBITMQ_URL
}
prometheus.scrape "rabbitmq_demo" {
targets = prometheus.exporter.rabbitmq.rabbitmq_demo.targets
forward_to = [prometheus.relabel.example.receiver]
}
- 使用APO Grafana内携带的
RabbitMQ 指标(kbudde/rabbitmq_exporter)
面板查看监控数据
配置说明:
prometheus.exporter.rabbitmq
块内可选配置如下,配置项均来自kbudde/rabbitmq_exporter
Environment variable | default | description |
---|---|---|
rabbit_url | http://127.0.0.1:15672 | url to rabbitMQ management plugin (must start with http(s)://) |
rabbit_user | guest | username for rabbitMQ management plugin. User needs monitoring tag! |
rabbit_password | guest | password for rabbitMQ management plugin |
rabbit_connection | direct | direct or loadbalancer, strips the self label when loadbalancer |
rabbit_user_file | location of file with username (useful for docker secrets) | |
rabbit_password_file | location of file with password (useful for docker secrets) | |
publish_port | 9419 | Listening port for the exporter |
publish_addr | "" | Listening host/IP for the exporter |
output_format | TTY | Log ouput format. TTY and JSON are suported |
log_level | info | log level. possible values: "debug", "info", "warning", "error", "fatal", or "panic" |
cafile | ca.pem | path to root certificate for access management plugin. Just needed if self signed certificate is used. Will be ignored if the file does not exist |
certfile | client-cert.pem | path to client certificate used to verify the exporter's authenticity. Will be ignored if the file does not exist |
keyfile | client-key.pem | path to private key used with certificate to verify the exporter's authenticity. Will be ignored if the file does not exist |
skipverify | false | true/0 will ignore certificate errors of the management plugin |
skip_vhost | ^$ | regex, matching vhost names are not exported. First performs INCLUDE_VHOST, then SKIP_VHOST. Applies to queues and exchanges |
include_vhost | .* | regex vhost filter. Only matching vhosts are exported. Applies to queues and exchanges |
include_queues | .* | regex queue filter. Just matching names are exported |
skip_queues | ^$ | regex, matching queue names are not exported (useful for short-lived rpc queues). First performed INCLUDE, after SKIP |
include_exchanges | .* | regex exchange filter. (Only exchanges in matching vhosts are exported) |
skip_exchanges | ^$ | regex, matching exchanges names are not exported. First performed INCLUDE, after SKIP |
rabbit_capabilities | bert,no_sort | comma-separated list of extended scraping capabilities supported by the target RabbitMQ server |
rabbit_exporters | exchange,node,queue | List of enabled modules. Possible modules: connections,shovel,federation,exchange,node,queue,memory |
rabbit_timeout | 30 | timeout in seconds for retrieving data from management plugin. |
max_queues | 0 | max number of queues before we drop metrics (disabled if set to 0) |
exclude_metrics | Metric names to exclude from export. comma-seperated. e.g. "recv_oct, recv_cnt". See exporter_*.go for names |